<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">

        姓：<input type="text" v-model="firstName">
        +名：<input type="text" v-model="lastName">
        =
        <p>{{fullName}}</p>
        <button @click="changName">改名</button>

    </div>


    <!-- 引入包 -->

    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script> -->
    <script src="./vue.js"></script>
    <!-- 创建实例 -->

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                firstName: '刘',
                lastName: '备',

            },
            methods: {

                changName() {

                    this.fullName = '刘备';
                }
            },
            computed: {
                fullName: {


                    get() {

                        return this.firstName + this.lastName;

                    },
                    set(value) {

                        this.firstName = value.slice(0, 1)
                        this.lastName = value.slice(1)
                    }



                }



            }

        })


    </script>
</body>

</html>